<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition template="/publico/template.xhtml">
        <ui:define 
            name="content">
            <h:form id="fprincipal">
                <p:messages/>
                <h:inputHidden id="ihnovoUsuarioid"
                               value="#{usuarioBean.usuario.id}" />
                <p:panel id="pprincipal" 
                         header="Cadastro">
                    <h:panelGrid columns="2">
                        <h:panelGrid id="pgprincipal"
                                     columns="2">
                            <h:outputLabel for="itnome" value="Nome: "/>
                            <p:inputText
                                id="itnome" 
                                value="#{usuarioBean.usuario.nome}"
                                required="true"/>

                            <h:outputLabel for="itlogin" value="Login: "/>
                            <p:inputText
                                id="itlogin" 
                                value="#{usuarioBean.usuario.login}"
                                required="true"/>
                            
                            <h:outputLabel for="pwd1" value="Senha: *" />  
                            <p:password id="pwd1" 
                                        value="#{usuarioBean.usuario.senha}"
                                        label="senha"
                                        required="true" 
                                        feedback="true"
                                        weakLabel="Fraco"
                                        goodLabel="Bom"
                                        strongLabel="Forte"/>
                        </h:panelGrid>

                        <h:panelGrid columns="2">
                            <p:selectManyCheckbox value="#{usuarioBean.usuario.papeis}"
                                                  layout="pageDirection"
                                                  converter="papelConversor">
                                <f:selectItems value="#{usuarioBean.papeis}"
                                               var="p"
                                               itemValue="#{p}"
                                               itemLabel="#{p.nome.substring(5)}"/>
                            </p:selectManyCheckbox>
                        </h:panelGrid>
                    </h:panelGrid>
                    <p>
                        <p:commandButton id="cbsalvar" 
                                         ajax="false"
                                         value="Salvar" 
                                         action="#{usuarioBean.salvar}"/>

                        <p:button id="cbcancelar"
                                  outcome="/admin/usuario/lista-usuario.xhtml"
                                  value="Cancelar"/>
                    </p>
                </p:panel> 
            </h:form>
        </ui:define>
    </ui:composition>
</html>
